{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "oYUfHXdS4_dv"
      },
      "source": [
        "Copyright 2023 Google LLC\n",
        "\n",
        "Licensed under the Apache License, Version 2.0 (the \"License\");\n",
        "you may not use this file except in compliance with the License.\n",
        "You may obtain a copy of the License at\n",
        "\n",
        "     https://www.apache.org/licenses/LICENSE-2.0\n",
        "\n",
        "Unless required by applicable law or agreed to in writing, software\n",
        "distributed under the License is distributed on an \"AS IS\" BASIS,\n",
        "WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n",
        "See the License for the specific language governing permissions and\n",
        "limitations under the License."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "ekPV8OfqHXe2"
      },
      "outputs": [],
      "source": [
        "# Notebook environment must have bert_score a as a build dependency.\n",
        "from cbertscore import bert_score_lib"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "9EiAKEmbHkXW"
      },
      "outputs": [],
      "source": [
        "# A pretrained BERT model can be downloaded from the following link and used\n",
        "# locally:\n",
        "# https://github.com/google-research/bert/blob/master/README.md\n",
        "model_dir = ''\n",
        "scorer = bert_score_lib.CBertScorer(model_dir)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "DxKILtdbITd-"
      },
      "outputs": [],
      "source": [
        "# You should call `scorer.score` as few times as possible to avoid the startup\n",
        "# time associated with the function. It is best to batch your inputs.\n",
        "\n",
        "candidates = ['candidate sentence', 'exact match']\n",
        "references = ['reference sentence', 'exact match']\n",
        "\n",
        "scorer.score(candidates, references, use_idf=False)"
      ]
    }
  ],
  "metadata": {
    "colab": {
      "last_runtime": {
        "build_target": "",
        "kind": "local"
      },
      "private_outputs": true,
      "provenance": [
        {
          "file_id": "12VNqWroscEqvtGyvLyEm8Fqfqd5tbpIN",
          "timestamp": 1689192273868
        },
        {
          "file_id": "1H6bSHYgAHpwJeE-wOTgj6rAhMFZBmVd6",
          "timestamp": 1563906782759
        }
      ]
    },
    "kernelspec": {
      "display_name": "Python 2",
      "name": "python2"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
